import React, { Component, lazy, Suspense } from 'react';
import { Route, Switch, Redirect } from 'react-router-dom'
// 引入loading组件
import Loading from '@/components/Loading'
//  使用懒加载的方式引入组件
const Welcome = lazy(() => import('@/views/dashboard/Welcome'))
const Cinema = lazy(() => import('@/views/dashboard/cinema/Index'))
const Film = lazy(() => import('@/views/dashboard/film/Index'))
const User = lazy(() => import('@/views/dashboard/user/Index'))
const College = lazy(() => import('@/views/dashboard/college/Index'))


class Admin extends Component {
    render() {
        return (
            <Suspense fallback={<Loading></Loading>}>
                <Switch>
                    {/* react 中的二级路由规则需要拼接一级path V6不需要*/}
                    <Route path='/dashboard/welcome' component={Welcome}></Route>
                    <Route path='/dashboard/user/index' component={User}></Route>
                    <Route path='/dashboard/cinema/index' component={Cinema}></Route>
                    <Route path='/dashboard/film/index' component={Film}></Route>
                    <Route path='/dashboard/college/index' component={College}></Route>
                    <Redirect from='/dashboard' to='/dashboard/welcome' exact></Redirect>
                </Switch>
            </Suspense>
        );
    }
}

export default Admin;
